﻿using System.Web.UI;

namespace Rosieks.Web.Flow
{
    public class LosFormatterWrapper : LosFormatterBase
    {
        private LosFormatter formatter;

        public LosFormatterWrapper(LosFormatter formatter)
        {
            this.formatter = formatter;
        }

        /// <summary>
        /// Transforms the view-state value contained in a System.IO.Stream object to
        /// a limited object serialization (LOS)-formatted object.
        /// </summary>
        /// <param name="stream">A System.IO.Stream that contains the view-state value to transform.</param>
        /// <returns>A LOS-formatted object.</returns>
        public override object Deserialize(System.IO.Stream stream)
        {
            return this.formatter.Deserialize(stream);
        }

        /// <summary>
        /// Transforms the specified view-state value to a limited object serialization
        /// (LOS)-formatted object.
        /// </summary>
        /// <param name="input">The view-state value to transform.</param>
        /// <returns>A LOS-formatted object.</returns>
        /// <exception cref="System.Web.HttpException">The view state is invalid.</exception>
        public override object Deserialize(string input)
        {
            return this.formatter.Deserialize(input);
        }

        /// <summary>
        /// Transforms the view-state value contained in a System.IO.TextReader object
        /// to a limited object serialization (LOS)-formatted object.
        /// </summary>
        /// <param name="input">A System.IO.TextReader that contains the view-state value to transform.</param>
        /// <returns>A LOS-formatted object.</returns>
        public override object Deserialize(System.IO.TextReader input)
        {
            return this.formatter.Deserialize(input);
        }

        /// <summary>
        /// Transforms a limited object serialization (LOS)-formatted object into a view-state
        /// value and places the results into a System.IO.Stream object.
        /// </summary>
        /// <param name="stream">The System.IO.Stream to receive the transformed value.</param>
        /// <param name="value">The LOS-formatted object to transform into a view-state value.</param>
        public override void Serialize(System.IO.Stream stream, object value)
        {
            this.formatter.Serialize(stream, value);
        }

        /// <summary>
        /// Transforms a limited object serialization (LOS)-formatted object into a view-state
        ///     value and places the results into a System.IO.TextWriter object.
        /// </summary>
        /// <param name="output">The System.IO.TextWriter to receive the transformed value.</param>
        /// <param name="value">The LOS-formatted object to transform into a view-state value.</param>
        public override void Serialize(System.IO.TextWriter output, object value)
        {
            this.formatter.Serialize(output, value);
        }
    }
}
